<?php

namespace app\common\model;


class ShopSiteGroupModel extends BaseModel
{
    protected $name = 'shop_site_group'; //定义用户表
    //开启自动写入时间戳
    protected $autoWriteTimestamp = false;
    // 定义自动完成的属性
    protected $auto = []; //新增修改
    protected $insert = []; //插入
    protected $update = []; //修改

    /**
     * 更新缓存
     */
    public function updateCache($siteId)
    {
        $category = $this->where('site_id',$siteId)->order('cat_order')->select()->toArray();
        $data     = [];
        foreach ($category as $v) {
            $isSon           = \org\util\TreeUtil::hasChild($category, $v['cid'], 'pid');
            $v['is_son']     = $isSon;
            $data[$v['cid']] = $v;
        }
        if (cache('shop_site_group'.$siteId, $data)) {
            return true;
        } else {
            return false;
        }
    }
}
